# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=nghttp3
pkgver=1.1.0
pkgrel=0
pkgdesc="HTTP/3 library written in C"
url="https://github.com/ngtcp2/nghttp3"
arch="all"
license="MIT"
makedepends="cmake samurai"
checkdepends="cunit-dev"
subpackages="$pkgname-dev"
source="https://github.com/ngtcp2/nghttp3/releases/download/v$pkgver/nghttp3-$pkgver.tar.gz"

build() {
	local crossopts=
	if [ "$CBUILD" != "$CHOST" ]; then
		crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -G Ninja -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		$crossopts .
	cmake --build build
}

check() {
	cmake --build build --target check
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Contains just README.rst.
	rm -rf "$pkgdir"/usr/share/doc
}

sha512sums="
64a91c7ddbcc043ed77e12c18264dfeccfe588add80211c3141fc428b16aaa14269d4f55df234a77c805c8f54ef47df5dd9ef916c31b2947ddcfb1fa2cd29fb6  nghttp3-1.1.0.tar.gz
"
